package 一四省B;

import java.util.Scanner;

public class q5 {

	public static int[] num = new int[100000];
	
	/**
	 * 根据已知区间求出丢失和重复值
	 * @param min
	 * @param max
	 * @param num
	 * @return
	 */
	public static int[] lostAndChongfu(int min,int max,int[] num){
		int[] result = new int[2];
		boolean flag1 = false;
		boolean flag2 = false;
		for(int i=min;i<=max;i++){
			if(num[i] == 0){
				result[0] = i;
				flag1 = true;
			}
			
			if(num[i] > 1){
				result[1] = i;
				flag2 = true;
			}
			
			if(flag1&&flag2){
				break;
			}
		}
		return result;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		//初始化
        for(int i=0;i<100000;i++){
        	num[i] = 0;
        }
		
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        
        while(n-->0){
        	String[] str =scanner.nextLine().split(" ");
        	for(int i=0;i<str.length;i++){
        		int k = Integer.parseInt(str[i]);
        		num[k]++;
        		if(k<min){
        			min = k;
        		}
        		
        		if(k>max){
        			max = k;
        		}
        	}
        }
        
        int[] result = lostAndChongfu(min,max,num);
        
        System.out.println(result[0] + " " + result[1]);
        
	}

}
